import { ConnectionManager } from './ConnectionManager.js';
import { DOMManager } from './DOMManager.js';
import { MessageHandler } from './MessageHandler.js';
import { FileHandler } from './FileHandler.js';

export class ChatApp {
  constructor() {
    this.nickname = localStorage.getItem('nickname') || null;
    this.clientId = localStorage.getItem('clientId');
    this.unreadCount = 0;

    this.domManager = new DOMManager(this);
    this.connectionManager = new ConnectionManager(this);
    this.messageHandler = new MessageHandler(this);
    this.fileHandler = new FileHandler(this);

    this.init();
  }

  init() {
    this.connectionManager.connectToServer();
  }

  setNickname(nickname) {
    this.nickname = nickname;
    localStorage.setItem('nickname', nickname);
  }

  setClientId(clientId) {
    this.clientId = clientId;
    localStorage.setItem('clientId', clientId);
  }
} 